package icraf.carbon.core;

import icraf.carbon.core.Zone.DataType;

public class DataItem implements OpcostData,  AbacusData {
	LandCover lc1;
	LandCover lc2;
	Zone z;

	public DataItem(Zone z, LandCover lc1, LandCover lc2) {
		this.z = z;
		this.lc1 = lc1;
		this.lc2 = lc2;
	}
	
	public void setData(Zone z, LandCover lc1, LandCover lc2) {
		this.z = z;
		this.lc1 = lc1;
		this.lc2 = lc2;
	}

	@Override
	public double getCost(CostBenefitUnit costBenefitUnit) {
		return getZone().getValue(lc1, lc2, DataType.OPCOST, costBenefitUnit);
	}

	/* (non-Javadoc)
	 * @see icraf.carbon.core.AbatementData#getEmission()
	 */
	@Override
	public double getEmission() {
		return getZone().getValue(lc1, lc2, DataType.EMISSION, null);
	}
	
//	public double getBelowgroundEmission() {
//		//the input is already on annual emission
//		return getZone().getValue(lc1, lc2, DataType.BELOWGROUND_EMISSION, null);
//	}

	@Override
	public LandCover getLandCover1() {
		return lc1;
	}

	@Override
	public LandCover getLandCover2() {
		return lc2;
	}

	@Override
	public Zone getZone() {
		return z;
	}
	
	@Override
	public String getGroup() {
		return getZone().getLabel();
	}

	@Override
	public String getLabel1() {
		return lc1.getLabel();
	}

	@Override
	public String getLabel2() {
		return lc2.getLabel();
	}

	@Override
	public boolean isEligible() {
		return getZone().isEligible()&&getZone().getProject().isEligible(lc1, lc2);
	}

	@Override
	public double getLandCoverChanges() {
		return getZone().getValue(lc1, lc2,
				DataType.LANDCOVER_CHANGE, null)*getZone().getAreaSize();
	}
}
